package com.aliang.shopping.model.converter;

import com.aliang.shopping.model.dto.common.UpdateStatusDTO;
import com.aliang.shopping.model.po.Cart;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;


/**
 * 购物车数据转换器
 */
@Mapper(componentModel = "Spring")
public interface CartConverter {

    /**
     * 将购物车插入数据传输对象转换为购物车实体
     *
     * @param insertDTO
     * @return
     */
    @Mappings({
            @Mapping(target = "goodsSkuId", source = "id"),
            @Mapping(target = "goodsNum", source = "status")
    })
    Cart toPoByInsertDTO(UpdateStatusDTO insertDTO);

    /**
     * 将购物车更新数据传输对象转换为购物车实体
     *
     * @param updateDTO
     * @return
     */
    @Mapping(target = "goodsNum", source = "status")
    Cart toPoByUpdateDTO(UpdateStatusDTO updateDTO);

}
